<?php
// +----------------------------------------------------------------------
// | Copyright (c) 2018-2018 http://www.donglixia.net All rights reserved.
// +----------------------------------------------------------------------
// | Author: 十万马 <962863675@qq.com>
// +----------------------------------------------------------------------
// | DateTime: 2018-02-09 16:17
// +----------------------------------------------------------------------

namespace app\admin_fussen\model;

use app\common\model\Base;
use think\Db;

class ArticleCat extends Base
{
    /**
     * 获取基本资料
     * @param array $map
     * @return false|\PDOStatement|string|\think\Collection
     */
    public function getBasicList($map = [])
    {
        $map['state'] = 1;
        $basic_ids = Db::name('basic_info')->where($map)->column('basic_id');//资料id
        return Db::name('basic_info')->whereIn('pid', $basic_ids)->where('state', 1)->field('basic_id,pid,cat_code,basic_code,basic_name')->order('sort_num')->select();
    }

    /**
     * 获取显示位置
     * @param $value
     * @return mixed
     */
    public function getLocationTextAttr($value)
    {
        return !empty($value) ? Db::name('basic_info')->where('basic_id', $value)->value('basic_name') : '';
    }

    /**
     * 获取所属板块
     * @param $value
     * @return mixed
     */
    public function getCatTypeTextAttr($value)
    {
        return !empty($value) ? Db::name('basic_info')->where('basic_id', $value)->value('basic_name') : '';
    }
}